package com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_month.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_month.entity.TWaterCostRecordsMonth;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xjrsoft.core.tool.utils.CollectionUtil;

import java.math.BigDecimal;
import java.util.ArrayList;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_month.dto.TWaterCostRecordsMonthListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import java.util.List;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_month.mapper.TWaterCostRecordsMonthMapper;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_month.service.ITWaterCostRecordsMonthService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author dongxinhang
 * @since 2023-09-05
 */
@Service
@AllArgsConstructor
public class TWaterCostRecordsMonthServiceImpl extends BaseService<TWaterCostRecordsMonthMapper, TWaterCostRecordsMonth> implements ITWaterCostRecordsMonthService {


	@Override
	public IPage<TWaterCostRecordsMonth> getPageList(TWaterCostRecordsMonthListDto pageListDto) {
		Wrapper<TWaterCostRecordsMonth> wrapper = Wrappers.<TWaterCostRecordsMonth>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getIdentify_name()), TWaterCostRecordsMonth::getIdentifyName, pageListDto.getIdentify_name())
				.like(!StringUtil.isEmpty(pageListDto.getRoom_number()), TWaterCostRecordsMonth::getRoomNumber, pageListDto.getRoom_number())
				.eq(!StringUtil.isEmpty(pageListDto.getMonth()), TWaterCostRecordsMonth::getMonth, pageListDto.getMonth())
				.eq(!StringUtil.isEmpty(pageListDto.getYear()), TWaterCostRecordsMonth::getYear, pageListDto.getYear());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public String addTWaterCostRecordsMonth(TWaterCostRecordsMonth tWaterCostRecordsMonth) {
		String tWaterCostRecordsMonthId = IdWorker.get32UUID();
		tWaterCostRecordsMonth.setFid(tWaterCostRecordsMonthId);
		boolean isSuccess = this.save(tWaterCostRecordsMonth);
		return isSuccess ? tWaterCostRecordsMonthId : null;
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

	@Override
	public int addTransitionData(String start, String end) {
		return this.getBaseMapper().addTransitionData(start+" 00:00:00",end+" 00:00:00");
	}

	@Override
	public int addSumData(String start, String end) {
		return this.getBaseMapper().addSumData(start, end);
	}

	@Override
	public int insertDataByDay(String start, String end) {
		return this.getBaseMapper().insertDataByDay(start, end);
	}

	@Override
	public void deleteWaterDate(String start, String end) {
		this.getBaseMapper().deleteWaterDate(start,end);
	}

	@Override
	public void deleteWaterCostRecordsMonth(String year, String month) {
		this.getBaseMapper().deleteWaterCostRecordsMonth(year, month);
	}

	@Override
	public void deleteWaterCostRecordsDay(String start, String end) {
		this.getBaseMapper().deleteWaterCostRecordsDay(start, end);
	}


}